package cn.elwy.rcp.kit;

import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

import cn.elwy.common.AppContext;
import cn.elwy.osgi.config.ConfigContext;
import cn.elwy.osgi.config.util.RcpPathSupport;

public class Activator extends AbstractUIPlugin {

	public static final String PLUGIN_ID = "cn.elwy.rcp.kit";
	private static BundleContext context;
	private static Activator plugin;
	
	static BundleContext getContext() {
		return context;
	}

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext bundleContext) throws Exception {
		Activator.context = bundleContext;
		plugin = this;
		AppContext.start(RcpPathSupport.getInstance());
		ConfigContext.init();
	}

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext bundleContext) throws Exception {
		Activator.context = null;
		AppContext.stop();
	}

	public static Activator getDefault() {
		return plugin;
	}

}
